<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.org/ui" 
        xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>Add Movie</title>
    </h:head>
    <h:body rendered="#{userService.currentUser.isLoggedIn}" >
        <div>
        <h:form id="form11">
            <p:commandButton value="Search" action="search.jsf" />
            <p:commandButton value="Upload" action="upload.jsf" />
            <p:commandButton value="Edit Movies" action="editmovie.jsf" />
            <p:commandButton value="Edit Movies For All" action="#{userService.easyAccessToEditMovie}" />
            <p:commandButton value="Logout" actionListener="#{userService.logout()}" />
            <!--<p:commandButton value="List Movies" action="allmovies.jsf" />-->
        </h:form>
            <h:form id="form" rendered="#{userService.currentUser.subscriber == 1}">
                <p:panel id="panel" header="New Movie" style="margin-bottom:10px;">  
                    <p:messages id="messages" /> 
                    <h:panelGrid columns="3" >
                        <p:outputLabel for="idfield" value="Id: " />
                        <p:spinner max="99999" min="0" stepFactor="1" required="true" id="idfield" value="#{movieService.currentMovie.id}" />
                        <p:message for="idfield" />

                        <p:outputLabel for="titlefield" value="Title: " />
                        <p:inputText id="titlefield" required="true" value="#{movieService.currentMovie.title}" />
                        <p:message for="titlefield" />

                        <p:outputLabel for="yearfield" value="Release Year: " />
                        <p:spinner max="2012" min="1900" stepFactor="1" id="yearfield" value="#{movieService.currentMovie.releaseYear}" />
                        <p:message for="yearfield" />

                        <p:outputLabel for="genrefield" value="Genre: " />
                        <p:inputText id="genrefield" value="#{movieService.currentMovie.genre}" />
                        <p:message for="genrefield" />
                    </h:panelGrid>
                </p:panel>
                <p:commandButton value="Add (secure)" update="panel" actionListener="#{movieService.addMovie(userService)}" />
                <p:commandButton value="Add (insecure)" actionListener="#{movieService.addMovieVulnerable(userService)}" />
            </h:form>
            <p:panel id="panel1" rendered="#{userService.currentUser.subscriber == 0}" >
                You are not a subscriber! You can't add new movies.
            </p:panel>
        </div>
    </h:body>
    <h:body rendered="#{userService.currentUser.isLoggedIn == false}">
        You're not allowed to be on this page, while not being logged in!
        <br/>
        <h:form>
            <p:commandLink id="redirectlink" action="index.jsf" >Log in</p:commandLink>
        </h:form>
    </h:body>
</html>
